package Executor;

import java.util.concurrent.ExecutorService;  
import java.util.concurrent.Executors;  
import java.util.concurrent.TimeUnit;
  
public class FixedThreadPoolTest {  
  
  public static void main(String[] args) {  
    try {  
      // 创建固定线程数的线程池，以共享的无界队列方式来运行这些线程  
      ExecutorService executorService = Executors.newFixedThreadPool(5);  
      for (int i =1; i <= 5; i++) {  
        executorService.execute(new Task(i));  
      }  
      executorService.shutdown();  
      executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);//所有线程执行完毕才进入下一步
      System.out.println("all thread complete");
    } catch (Exception e) {
    	
    }  
  }  
} 
